// 订单状态枚举
export const ORDER_STATUS = {
  PENDING_PAYMENT: "PENDING_PAYMENT", // 待支付
  PAID: "PAID", // 已支付
  CANCELLED: "CANCELLED", // 已取消
  COMPLETED: "COMPLETED", // 已完成
};
// 订单状态映射表
export const STATUS_MAP = {
  1: ORDER_STATUS.PENDING_PAYMENT, // 未付款
  2: ORDER_STATUS.CANCELLED, // 未付款超时取消
  3: ORDER_STATUS.PAID, // 已付款待发货
  4: ORDER_STATUS.PAID, // 已发货
  5: ORDER_STATUS.PAID, // 已签收
  6: ORDER_STATUS.CANCELLED, // 已付款未发货取消
  7: ORDER_STATUS.CANCELLED, // 申请退换货审核中
  8: ORDER_STATUS.CANCELLED, // 同意退换货待运输
  9: ORDER_STATUS.PAID, // 收到退换货
  10: ORDER_STATUS.PAID, // 退换货运输中
  11: ORDER_STATUS.PAID, // 退换货完成
  12: ORDER_STATUS.PAID, // 商品完成评价
  13: ORDER_STATUS.CANCELLED, // 退款中 
  14: ORDER_STATUS.CANCELLED, // 退款完成
  15: ORDER_STATUS.CANCELLED, // 用户正常取消
  16: ORDER_STATUS.CANCELLED, // 门店取消
};

// 订单状态显示文本
export const STATUS_TEXT = {
  [ORDER_STATUS.PENDING_PAYMENT]: "待支付",
  [ORDER_STATUS.PAID]: "已支付",
  [ORDER_STATUS.CANCELLED]: "已取消",
  [ORDER_STATUS.COMPLETED]: "已完成",
};

// 状态样式类
export const STATUS_CLASS = {
  [ORDER_STATUS.PENDING_PAYMENT]: "status-pending",
  [ORDER_STATUS.PAID]: "status-paid",
  [ORDER_STATUS.CANCELLED]: "status-canceled",
  [ORDER_STATUS.COMPLETED]: "status-completed",
};

// 后端课程状态枚举
export const COURSE_STATUS = {
  PREPARING: 1, // 筹备中
  READY_WAITING: 2, // 筹备完成等待中
  READY_LOCKED: 3, // 筹备完成不可取消
  IN_PROGRESS: 4, // 上课中
  COMPLETED: 5, // 已完成
  USER_CANCELLED: 6, // 用户正常取消
  USER_ABSENT: 7, // 用户未签到取消
  TEACHER_CANCELLED: 8, // 老师取消
  STORE_CANCELLED: 9, // 门店取消
};

// 前端展示状态枚举
export const DISPLAY_STATUS = {
  UPCOMING: "upcoming", // 待上课
  COMPLETED: "completed", // 已完成
  CANCELLED: "cancelled", // 已旷课
};

// 状态映射表：后端状态 -> 前端展示状态
export const COURSE_STATUS_MAP = {
  [COURSE_STATUS.PREPARING]: DISPLAY_STATUS.UPCOMING, // 筹备中 -> 待上课
  [COURSE_STATUS.READY_WAITING]: DISPLAY_STATUS.UPCOMING, // 筹备完成等待中 -> 待上课
  [COURSE_STATUS.READY_LOCKED]: DISPLAY_STATUS.UPCOMING, // 筹备完成不可取消 -> 待上课
  [COURSE_STATUS.IN_PROGRESS]: DISPLAY_STATUS.COMPLETED, // 上课中 -> 待上课
  [COURSE_STATUS.COMPLETED]: DISPLAY_STATUS.COMPLETED, // 已完成 -> 已完成
  [COURSE_STATUS.USER_CANCELLED]: DISPLAY_STATUS.CANCELLED, // 用户正常取消 -> 已旷课
  [COURSE_STATUS.USER_ABSENT]: DISPLAY_STATUS.CANCELLED, // 用户未签到取消 -> 已旷课
  [COURSE_STATUS.TEACHER_CANCELLED]: DISPLAY_STATUS.CANCELLED, // 老师取消 -> 已旷课
  [COURSE_STATUS.STORE_CANCELLED]: DISPLAY_STATUS.CANCELLED, // 门店取消 -> 已旷课
};

// 前端展示状态到后端状态的映射（用于请求时的状态过滤）
export const DISPLAY_STATUS_TO_BACKEND = {
  [DISPLAY_STATUS.UPCOMING]: [1, 2, 3], // 待上课状态包含的后端状态
  [DISPLAY_STATUS.COMPLETED]: [4, 5], // 已完成状态
  [DISPLAY_STATUS.CANCELLED]: [6, 7, 8, 9], // 已旷课状态
};
// 状态到UI展示和按钮行为的映射
export const STATUS_UI_MAP = {
  // 待完成状态
  1: {
    group: "upcoming",
    text: "筹备中",
    showCancel: true,
    showCheckIn: true,
  },
  2: {
    group: "upcoming",
    text: "筹备完成等待中",
    showCancel: true,
    showCheckIn: true,
  },
  3: {
    group: "upcoming",
    text: "筹备完成不可取消",
    showCancel: true,
    showCheckIn: true,
  },

  // 已完成状态
  4: {
    group: "completed",
    text: "上课中",
    showCheckedIn: true,
    showEvaluate: false,
  },
  5: {
    group: "completed",
    text: "已完成",
    showCheckedIn: false,
    showEvaluate: true,
  },

  // 已取消状态
  6: { group: "cancelled", text: "用户已取消", showPenalty: true },
  7: { group: "cancelled", text: "未签到取消", showPenalty: true },
  8: { group: "cancelled", text: "教师已取消", showPenalty: true },
  9: { group: "cancelled", text: "门店已取消", showPenalty: true },
};
